package nosql

import (
	"RocFamilySystem/config"
	"RocFamilySystem/tools/container"
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"log"
)

func InitRedis() {
	conf := config.GlobalConfig.Redis

	RedisClient := redis.NewClient(&redis.Options{
		Addr:     fmt.Sprintf("%s:%d", conf.Host, conf.Port),
		Password: conf.Password,
		DB:       conf.Db,
	})

	ping := RedisClient.Ping(context.Background())

	if ping.Err() != nil {
		log.Panicln("redis错误：", ping.Err().Error())
	}
	container.PushContainer(RedisClient)
}
